package com.zzl.bonds.ticket.feign;

import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.bonds.ticket.dto.feign.ContractAddDto;
import com.zzl.bonds.ticket.dto.feign.SealApproveDto;
import com.zzl.bonds.ticket.dto.feign.SignerEntity;
import com.zzl.bonds.ticket.dto.feign.TemplateEntity;
import com.zzl.general.common.apidoc.annotation.ApidocResultKeyValR;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.apidoc.constants.ResultTypeInR;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.feign.config.FeignClientsConfig;
import com.zzl.general.common.utils.LogUtils;
import com.zzl.general.common.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 直连安心签的feign接口
 *
 * @author gulili
 */
@FeignClient(value = "anxinsign", configuration = FeignClientsConfig.class)
public interface AnXinSignFeign {

    @GetMapping("anxinsign/feign/getTemplateByBusinessType/{businessType}")
    @ApidocOperation(description = "通过id获取合同模板数据", operationId = "anxinsign/template" + "/getTemplateByBusinessType/id")
    @ApidocReturnR(otherkv = {
            @ApidocResultKeyValR(resultType = ResultTypeInR.TYPE_OBJECT, key = "template", valueClass = TemplateEntity.class)
    })
    List<TemplateEntity> getTemplateByBusinessType(@ApidocParam(description = "业务类型", name = "businessType", required = true) @PathVariable("businessType") Integer businessType);

    @PostMapping("anxinsign/feign/saveContract")
    @ApidocOperation(description = "新增电子合同", operationId = "anxinsign/contract" + "/save")
    @ApidocReturnR
    Result saveContract(@ApidocParam(description = "保存的电子合同对象值", name = "contract", required = true) @RequestBody List<ContractAddDto> contract);

    @PostMapping("anxinsign/feign/getContractSigner")
    @ApidocOperation(description = "查询合同的签署人状态", operationId = "anxinsign/template" + "/getContractSigner/id")
    @ApidocReturnR(otherkv = {
            @ApidocResultKeyValR(resultType = ResultTypeInR.TYPE_OBJECT, key = "template", valueClass = TemplateEntity.class)
    })
    List<SignerEntity> getContractSigner(@ApidocParam(description = "合同id集合", name = "contractIdList", required = true) @RequestBody List<String> contractIdList);

    @PostMapping("anxinsign/feign/approve")
    @ApidocOperation(description = "电子签章审核", operationId = "anxinsign/seal/approve")
    @ApidocReturnR
    Result approveSeal(@ApidocParam(description = "保存的电子签章对象值", name = "seal", required = true) @Validated @RequestBody SealApproveDto seal);


}
